from gui import config
import pprint

def setConfig():
    thisTranslation = {
        'areyousure': 'Are you sure?',
        'audio': 'Audio',
        'chat': 'Chat',
        'chatContext': 'Chat Context',
        'choices': 'Choices',
        'clearAll': 'Clear All',
        'configure': 'Chat Settings',
        'editable': 'Editable',
        'exit': 'Exit',
        'exitTheApplication': 'Exit the Application',
        'font': 'Font',
        'fontSize': 'Font Size',
        'help': 'Help',
        'image': 'Image',
        'language': 'Language',
        'messageHere': 'Enter your message here ...',
        'new': 'New',
        'optional': 'optional',
        'print': 'Print',
        'remove': 'Remove',
        'required': 'required',
        'save': 'Save',
        'searchContent': 'Search Content',
        'searchContentHere': 'Search content here ...',
        'searchTitle': 'Search Title',
        'searchTitleHere': 'Search title here ...',
        'send': 'Send',
        'stop': 'Stop',
        'settings': 'Settings',
        'show': 'Show',
        'temperature': 'Temperature',
        'toggleDarkTheme': 'Toggle Dark Theme',
        'toggleSystemTray': 'Toggle System Tray',
        'voice': 'voice',
        'voiceTyping': 'voice typing',
        'newDatabase': 'New Database',
        'openDatabase': 'Open Database',
        'saveDatabaseAs': 'Save Database as ...',
        'newChat': 'New Chat',
        'saveChat': 'Save Chat',
        'exportChat': 'Export Chat',
        'printChat': 'Print Chat',
        'replace': 'Replace',
        'replaceWith': 'Replace with',
        'searchFor': 'Search for',
        'replaceSelectedText': 'Replace selected text',
        'matchingRegularExpression': 'matching regular expression',
        'all': 'ALL',
        'replaceAll': 'Replace All',
        'toggleRegexp': 'Toggle Regular Expression',
        'fileManager': 'Database Directory',
        'pluginDirectory': 'Plugins Directory',
        'predefinedContext': 'Predefined Context',
        'toggleMultilineInput': 'Toggle Multiline User Input',
        'latestOnlineSearchResults': 'Latest Online Search Results',
        'maximumOnlineSearchResults': 'Maximum Online Search Results',
        'include': 'Include',
        'applyContext': 'Apply Context in',
        'firstInputOnly': 'First Input Only',
        'allInputs': 'All Inputs',
        'autoScroll': 'Auto Scroll',
        'enable': 'Enable',
        'countPromptTokens': 'Count Prompt Tokens',
        'textSelection': 'Text Selection',
        'webBrowser': 'Web Browser',
        'runAsSystemCommand': 'Run as System Command',
        'runAsPythonCommand': 'Execute as Python Script',
        'plugins': 'Plugins',
        'chatAfterFunctionCalled': 'Chat with Function Response',
        'runPythonScriptGlobally': 'Run Python Script Globally',
        'readTextFile': 'Read Text File',
        'customise': 'Customise',
        'repository': 'Repository',
        'about': 'About',
        'donate': 'Donate',
    }
    defaultSettings = (
        ('chatGPTApiAudio', 0),
        ('chatGPTApiAudioLanguage', 'en'),
        ('chatGPTApiModel', 'gpt-4'),
        ('chatGPTApiPredefinedContext', '[none]'),
        ('chatGPTApiContext', ''),
        ('chatGPTApiLastChatDatabase', ''),
        ('chatGPTApiMaxTokens', 512),
        ('chatGPTApiNoOfChoices', 0),
        ('chatGPTApiTemperature', 0.8),
        ('chatGPTApiFunctionCall', "none"),
        ('chatAfterFunctionCalled', True),
        ('runPythonScriptGlobally', False),
        ('darkTheme', True),
        ('developer', False),
        ('enableSystemTray', False),
        ('fontSize', 14),
        ('openaiApiBase', 'http://rd-gateway.patsnap.io/v1'),
        ('openaiApiKey', ''),
        ('openaiApiOrganization', ''),
        ('pocketsphinxModelPath', ''),
        ('pocketsphinxModelPathBin', ''),
        ('pocketsphinxModelPathDict', ''),
        ('qtLibrary', 'pyside6'),
        ('regexpSearchEnabled', True),
        #('includeDuckDuckGoSearchResults', False),
        #('maximumDuckDuckGoSearchResults', 5),
        ('loadingInternetSearches', "none"),
        ('maximumInternetSearchResults', 5),
        ('chatGPTApiContextInAllInputs', False),
        ('chatGPTApiAutoScrolling', True),
        ('thisTranslation', thisTranslation),
        ('chatGPTPluginExcludeList', ['testing_function_calling', 'zzz_automation_example']),
    )
    for key, value in defaultSettings:
        if not hasattr(config, key):
            value = pprint.pformat(value)
            exec(f"""config.{key} = {value} """)
    for i in thisTranslation:
        if not i in config.thisTranslation:
            config.thisTranslation[i] = thisTranslation[i]

setConfig()